package cn.wolfcode.controller;

import cn.wolfcode.domain.Comment;
import cn.wolfcode.qo.CommentQuery;
import cn.wolfcode.result.JsonResult;
import cn.wolfcode.service.ICommentService;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
* 评论控制层
*/
@Controller
@RequestMapping("comment")
public class CommentController {

    @Autowired
    private ICommentService commentService;

    @RequestMapping("/list")
    public String list(Model model, @ModelAttribute("qo") CommentQuery qo){
        IPage<Comment> page = commentService.queryPage(qo);
        model.addAttribute("page", page);
        return "comment/list";
    }

    @RequestMapping("/detail")
    @ResponseBody
    public Object detail(Long id){
        return new JsonResult(true,null);
    }

    @RequestMapping("/saveOrUpdate")
    @ResponseBody
    public Object saveOrUpdate(Comment comment){
        commentService.saveOrUpdate(comment);
        return new JsonResult(true,null);
    }


}
